/*
 * @Author: zhengzhuang
 * @Date: 2020-05-16 15:28:16
 * @LastEditors: zhengzhuang
 * @LastEditTime: 2020-12-11 14:24:29
 * @Description: app司机位置信息(全局)
 * @FilePath: /C20Driver/lib/provider/position_information.dart
 */

import 'package:amap_map_fluttify/amap_map_fluttify.dart';
import 'package:flutter/material.dart';

/// 全局位置信息
class PositionInformation with ChangeNotifier {
  String _driverCurrentCity = "选择城市";

  /// 司机所在城市
  String get driverCurrentCity => _driverCurrentCity;

  /// 司机位置经纬度
  LatLng _driverLocation;

  /// 司机位置地点名称
  String _locationName;

  /// 司机目的地位置经纬度
  LatLng _driverDesLocation;

  /// 司机目的地位置地点名称
  String _driverDesLatName;

  /// 司机目的地城市
  String _driverDesLatCity;
  LatLng get driverLocation => _driverLocation;
  String get locationName => _locationName;
  LatLng get driverDesLocation => _driverDesLocation;
  String get driverDesLatName => _driverDesLatName;
  String get driverDesLatCity => _driverDesLatCity;

  /// 设置司机当前城市(经纬度)
  void setCityLocation(String cityName, double lat, double lng, String address,
      BuildContext context) {
    if (cityName != null && cityName.length > 0) {
      _driverCurrentCity = cityName;
      _driverLocation = LatLng(lat, lng);
      _locationName = address;
      notifyListeners();
    }
  }

  /// 设置城市名称
  void setCityName(String cityName) {
    if (cityName != null && cityName.length > 0) {
      _driverCurrentCity = cityName;
      notifyListeners();
    }
  }

  /// 持续设置车主实时位置
  setRealtimeDriverPosition(context, latitude, longitude, userId) {
    _driverLocation = LatLng(latitude, longitude);
    notifyListeners();
  }
}
